<template>
  <el-dialog
    :title="title"
    :modelValue="visible"
	 :close-on-click-modal="false"
    :top="top"
    :width="width"
    :destroy-on-close="destroyOnClose"
    @closed="close"
  >
    <div class="dialog-content">
      <slot></slot>
    </div>
    <template #footer v-if="showBtn">
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="confirm">确 认</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
	import {
		defineProps,
		defineEmits
	} from "vue";
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    default: ''
  },
  width: {
    type: [String, Number],
    default: 800
  },
  top: {
    type: String,
    default: ''
  },
  destroyOnClose: {
    type: Boolean,
    default: true
  },
  showBtn: {
    type: Boolean,
    default: true
  },
})
const emit = defineEmits(['confirm', 'cancel', 'close'])
// 提交
const confirm = () => {
  emit('confirm')
}
// 取消
const cancel = () => {
  emit('cancel')
}
// 关闭
const close = () => {
  emit('close')
}
</script>
  
<style scoped>
.dialog-footer {
  text-align: right;
}
</style>
  